#include "lost-kingdom.h"

playsound* snd_menu;
mens* player;
playsound* snd_gameover;

char* buf_credits;
char* buf_begin;

bool domenu = true;
int keuze;
int ras;

int main()
{
    char janee = 'N';
    char naam[30];
    
	srand(time(NULL));
	
	buf_credits = textNaarBuffer("data/credits");
	snd_menu = new playsound("data/menu.ogg");
	snd_gameover = new playsound("data/game_over.ogg");
	snd_menu->Playmusic(true);
	
	while(domenu == true)
	{
		keuze = doemenu();
		switch(keuze)
		{
			case MENU_CREDITS:
				cout << buf_credits << endl;
			break;
			
			case MENU_EXIT:
				domenu = false;
				exit(0);
			break;
			
			case MENU_OPTIONS:
				cout << "Nog niet geïmplementeerd" << endl;
			break;
			
			case MENU_NEWGAME:
				snd_menu->Stopmusic();
				domenu = false;
			break;
			
		}
	}
	
	buf_begin = textNaarBuffer("data/begin");
	cout << buf_begin << endl;
	
    for(;;)
    {
        cout << "VOER NAAM SPEELER IN: ";
        scanf("%s", &naam);

        cout << "Wilt u deze naam  "<< naam << " behouden? J/N: ";
        cin >> janee;

        janee = toupper(janee);

        if(janee == 'J') break;

    }

    cout << "KIES EEN RAS" << endl;
    cout << "1-ORC  zijn sterker maar trager " << endl;
    cout << "2-MENS  zijn even sterk als snel " << endl;
    cout << "3-ELF  zijn sneller maar minder sterk "<< endl;
    cin >> ras;
    cout << "U KOOS VOOR";
    switch (ras) {
    case 1:
        {
            cout << " ORC" << endl;
            player = leesSpelerGegevens(ORC);
            break;
        }
    case 2:
        {
            cout <<" MENS" << endl;
            player = leesSpelerGegevens(HUMAN);
            break;
        }
    case 3:
        {
            cout << " ELF" << endl;
            player = leesSpelerGegevens(ELF);
            break;
        }
    }
    
    while(player->getLeven() > 0)
    {
		maakKeuze(player);
	}
    
    cout << "Game over" << endl;
    snd_gameover->Playmusic();
    
    while(snd_gameover->getPlaying() == true)
    {
		sleep(1);
	}
    
    delete player;
    delete snd_gameover;
    delete snd_menu;
    return 0;
}
